package net.minhdiep.androiddialoglistener.components;
/*
 * User: Minh Diep
 * Date: 5/19/13
 * Time: 12:09 AM
 */

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class SubBroadcastReceiver extends BroadcastReceiver {

    public static final String INTENT_FILTER_NAME = "net.minhdiep.broadcast.receiver.intent.filter.name";
    public static final String DATA_RECEIVE_ACTION = "net.minhdiep.broadcast.receiver.data.receive.action";
    public static final String DATA_RECEIVE_STR = "net.minhdiep.broadcast.receiver.data.receive.str";
    private onListener mListener;

    public SubBroadcastReceiver(Activity activity){
        mListener = (onListener) activity;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        String result = intent.getStringExtra(DATA_RECEIVE_STR);
        Log.d(this.getClass().getSimpleName(), result);

        if (DATA_RECEIVE_ACTION.equals(action)){
            mListener.onFinishDownloadXml(result);
        }
    }

    public interface onListener{
        public void onFinishDownloadXml(String s);
    }
}
